package jcurses.widgets;

import bubuntux.jusbscan.core.Configs;

public class ProgressBar extends TextField {

	private int totalFiles;
	private int actualProgress;

	public void addProgress() {
		this.actualProgress++;
		if (actualProgress > totalFiles) {
			actualProgress = totalFiles;
		}
		int lines = actualProgress * (Configs.stringLength - 1) / totalFiles;
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < lines; i++) {
			sb.append('/');
		}
		this.setText(sb.toString());
	}

	public void reset() {
		this.setText("");
		this.actualProgress = 0;
	}

	public void setTotalFiles(int filesCount) {
		this.totalFiles = filesCount;
	}
}
